
pkgname=logrotate
pkgver=3.14.0
pkgrel=1
pkgdesc="Rotates system logs automatically"
url='https://github.com/logrotate/logrotate'
arch=('x86_64')
license=('GPL')
groups=('base')
depends=('popt' 'gzip' 'acl')
backup=('etc/logrotate.conf')
source=("https://github.com/logrotate/logrotate/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz"
        'logrotate.conf')
md5sums=('1c0f6e6e490c4bcac0a1e77ad1310683'
         '416de14f92ef4361adad8b6e7065245a')

build() {
  cd ${pkgname}-${pkgver}
  
  ./configure --prefix=/usr \
    --mandir=/usr/share/man \
    --with-acl \
    --with-state-file-path=/var/lib/logrotate.status \
    --with-default-mail-command=/usr/bin/mail \
    --with-compress-command=/usr/bin/gzip \
    --with-uncompress-command=/usr/bin/gunzip \
    --with-compress-extension=.gz
  
  make 
}

check() {
  cd ${pkgname}-${pkgver}
  
  make test
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=$pkgdir install
  
  install -dm755 $pkgdir/etc/logrotate.d
  install -Dm644 $srcdir/logrotate.conf $pkgdir/etc/logrotate.conf
  
  install -D -m644 examples/logrotate.timer ${pkgdir}/usr/lib/systemd/system/logrotate.timer
  install -D -m644 examples/logrotate.service ${pkgdir}/usr/lib/systemd/system/logrotate.service
  install -d -m755 ${pkgdir}/usr/lib/systemd/system/multi-user.target.wants
  ln -s ../logrotate.timer ${pkgdir}//usr/lib/systemd/system/multi-user.target.wants/logrotate.timer
}
